home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / misc / a8085.lha / A8085 V1.0 / SRC / Kernal.a < prev    next >
Text File  |  1995-07-31  |  3KB  |  170 lines

  1. ; Jumptable
  2.           org $FF00
  3.  
  4.           jmp div
  5.           jmp mul
  6.           jmp print
  7.           jmp printbcd
  8.           jmp printacc
  9.           jmp readstr
  10.           jmp readnum
  11.  
  12.  
  13.           org  $F000
  14. ; Print the text where (HL) points to until $00
  15. ; (HL) points to the byte after $00
  16. print:    push psw
  17.           jmp  begin
  18. loop1:    out  (0)
  19. begin:    mov  a,m
  20.           inx  h
  21.           ora  a
  22.           jnz  loop1
  23.           pop  psw
  24.           ret
  25.  
  26. ; Print the BCD number in accumulator
  27. printbcd: push psw
  28.           rrc
  29.           rrc
  30.           rrc
  31.           rrc
  32.           ani  %00001111
  33.           jz   nonull1
  34.           adi  48
  35.           out  (0)
  36. nonull1:  pop  psw
  37.           push psw
  38.           ani  %00001111
  39.           adi  48
  40.           out  (0)
  41.           pop  psw
  42.           ret
  43.  
  44. ; Print the number in accumulator
  45. printacc: push psw
  46.           push bc
  47.           mvi  b,100
  48.           call div
  49.           mov  b,a
  50.           mov  a,c
  51.           ora  a
  52.           jz   nonull2
  53.           adi  48
  54.           out  (0)
  55. nonull2:  mov  a,b
  56.           mvi  b,10
  57.           call div
  58.           mov  b,a
  59.           mov  a,c
  60.           ora  a
  61.           jz   nonull3
  62.           adi  48
  63.           out  (0)
  64. nonull3:  mov  a,b
  65.           adi  48
  66.           out  (0)
  67.           pop  bc
  68.           pop  psw
  69.           ret
  70.  
  71. ; read maximum of accu+1 bytes to where (HL) points to
  72. ; (HL) points to the $00 that is appended to the text
  73. ; the number of actual bytes read can be found in the accu
  74. readstr:  push bc
  75.           mov  b,a
  76.           mov  c,a
  77. loop4:    in   (0)
  78.           cpi  8
  79.           jnz  noback
  80.           mov  a,b
  81.           cmp  c
  82.           jz   loop4     ;not allowed
  83.           inr  b
  84.           dcx  h
  85.           mvi  a,8
  86.           out  (0)
  87.           mvi  a,32
  88.           out  (0)
  89.           mvi  a,8
  90.           out  (0)
  91.           jmp  loop4
  92. noback:   cpi  13
  93.           jz   end
  94.           out  (0)
  95.           mov  m,a
  96.           inx  h
  97.           dcr  b
  98.           jnz  loop4
  99. end:      mvi  m,0
  100.           mov  a,c
  101.           sub  b
  102.           pop  bc
  103.           ret
  104.  
  105. ; returns read number in accumulator, flags destroyed
  106. readnum:  push de
  107.           push bc
  108.           mvi  d,3
  109.           mvi  e,0
  110. loop5:    in   (0)
  111.           cpi  8
  112.           jnz  noback2
  113.           mov  a,d
  114.           cpi  3
  115.           jz   loop5     ;not allowed
  116.           inr  d
  117.           mvi  a,8
  118.           out  (0)
  119.           mvi  a,32
  120.           out  (0)
  121.           mvi  a,8
  122.           out  (0)
  123.           mov  a,e
  124.           mvi  b,10
  125.           call div
  126.           mov  e,c
  127.           jmp  loop5
  128. noback2:  cpi  13
  129.           jz   end2
  130.           cpi  48
  131.           jc   loop5     ;char<"0"
  132.           cpi  57+1
  133.           jnc  loop5     ;char>"9"
  134.           out  (0)
  135.           sui  48
  136.           mov  b,a
  137.           mov  a,e
  138.           mov  e,b
  139.           mvi  b,10
  140.           call mul
  141.           add  e
  142.           mov  e,a
  143.           dcr  d
  144.           jnz  loop5
  145. end2:     mvi  m,0
  146.           mov  a,e
  147.           pop  bc
  148.           pop  de
  149.           ret
  150.  
  151. ; A:=A MOD B, C:=A DIV B, B unchanged and flags as after `CPI 0' command
  152. ; WARNING: Does not return for B=0
  153. div:      mvi  c,$FF
  154. loop2:    sub  b
  155.           inr  c
  156.           jnc  loop2
  157.           add  b
  158.           ret
  159.  
  160. ; A:=A*B, C:=A, B:=0, flags destroyed
  161. mul:      mov  c,a
  162.           mov  a,b
  163.           ora  a
  164.           rz
  165.           mvi  a,0
  166. loop3:    add  c
  167.           dcr  b
  168.           jnz  loop3
  169.           ret
  170.